/*     */ package com.umeng.analytics;
/*     */ 
/*     */ import android.content.Context;
/*     */ import android.content.SharedPreferences;
/*     */ import android.content.SharedPreferences.Editor;
/*     */ import android.text.TextUtils;
/*     */ import com.umeng.analytics.a.m;
/*     */ import com.umeng.analytics.a.o;
/*     */ import com.umeng.common.Log;
/*     */ import java.util.ArrayList;
/*     */ import java.util.HashMap;
/*     */ import java.util.Map;
/*     */ import java.util.Map.Entry;
/*     */ import java.util.Stack;
/*     */ import java.util.concurrent.ExecutorService;
/*     */ import java.util.concurrent.Executors;
/*     */ 
/*     */ class b extends d
/*     */ {
/*  30 */   public ExecutorService a = Executors.newSingleThreadExecutor();
/*     */   private String m;
/*     */   private String n;
/*  35 */   private final int o = 0;
/*  36 */   private final int p = 1;
/*     */ 
/*  38 */   String b = "";
/*  39 */   String c = "";
/*     */ 
/*  41 */   private final String q = "start_millis";
/*  42 */   private final String r = "end_millis";
/*     */ 
/*  44 */   private final String s = "last_fetch_location_time";
/*  45 */   private final long t = 10000L;
/*     */ 
/*  47 */   private final int u = 128;
/*  48 */   private final int v = 256;
/*     */ 
/*  50 */   private final Stack<f> w = new Stack();
/*  51 */   private final ArrayList<f> x = new ArrayList();
/*     */ 
/*     */   void a(String paramString)
/*     */   {
/*     */     try
/*     */     {
/*  59 */       this.w.push(new f(paramString, System.currentTimeMillis()));
/*     */     } catch (Exception localException) {
/*  61 */       localException.printStackTrace();
/*     */     }
/*     */   }
/*     */ 
/*     */   void b(String paramString) {
/*     */     try {
/*  67 */       if ((!this.w.isEmpty()) && (((f)this.w.peek()).a.equals(paramString))) {
/*  68 */         f localf = (f)this.w.pop();
/*  69 */         long l = System.currentTimeMillis() - localf.b;
/*     */ 
/*  72 */         localf.b = l;
/*  73 */         this.x.add(localf);
/*     */       } else {
/*  75 */         Log.e("MobclickAgent", "onPageEnd called without 'PageName' from corresponding onPageStart");
/*     */       }
/*     */     } catch (Exception localException) {
/*  78 */       localException.printStackTrace();
/*     */     }
/*     */   }
/*     */ 
/*     */   void a(String paramString1, String paramString2) {
/*  83 */     this.e.E = paramString1;
/*  84 */     this.e.F = paramString2;
/*     */   }
/*     */ 
/*     */   void a(Context paramContext) {
/*     */     try {
/*  89 */       if (paramContext == null) {
/*  90 */         Log.b("MobclickAgent", "unexpected null context in onPause");
/*  91 */         return;
/*     */       }
/*     */ 
/*  94 */       if (!paramContext.getClass().getName().equals(this.m)) {
/*  95 */         Log.b("MobclickAgent", "onPause() called without context from corresponding onResume()");
/*  96 */         return;
/*     */       }
/*     */ 
/*  99 */       this.a.execute(new a(paramContext, 0));
/*     */     } catch (Exception localException) {
/* 101 */       Log.b("MobclickAgent", "Exception occurred in Mobclick.onRause(). ", localException);
/*     */     }
/*     */   }
/*     */ 
/*     */   void a(Context paramContext, String paramString) {
/* 106 */     if (TextUtils.isEmpty(paramString)) {
/* 107 */       return;
/*     */     }
/*     */ 
/* 110 */     if (paramContext == null)
/*     */     {
/* 112 */       Log.b("MobclickAgent", "unexpected null context in reportError");
/* 113 */       return;
/*     */     }
/*     */ 
/* 116 */     this.d.a(new com.umeng.analytics.a.d(paramString));
/*     */ 
/* 118 */     e(paramContext);
/*     */   }
/*     */ 
/*     */   void a(Context paramContext, Throwable paramThrowable) {
/* 122 */     if ((paramContext == null) || (paramThrowable == null)) {
/* 123 */       return;
/*     */     }
/*     */ 
/* 126 */     this.d.a(new com.umeng.analytics.a.d(paramThrowable));
/*     */ 
/* 128 */     e(paramContext);
/*     */   }
/*     */ 
/*     */   private void h(Context paramContext)
/*     */   {
/* 163 */     if (paramContext == null) {
/* 164 */       Log.b("MobclickAgent", "unexpected null context in onResume");
/* 165 */       return;
/*     */     }
/*     */ 
/* 173 */     this.m = paramContext.getClass().getName();
/*     */   }
/*     */ 
/*     */   void b(Context paramContext)
/*     */   {
/*     */     try {
/* 179 */       h(paramContext);
/*     */ 
/* 181 */       this.a.execute(new a(paramContext, 1));
/*     */     }
/*     */     catch (Exception localException) {
/* 184 */       Log.b("MobclickAgent", 
/* 185 */         "Exception occurred in Mobclick.onResume(). ", localException);
/*     */     }
/*     */   }
/*     */ 
/*     */   void c(Context paramContext) {
/*     */     try {
/* 191 */       a(paramContext, 2);
/*     */     } catch (Exception localException) {
/* 193 */       Log.b("MobclickAgent", "Exception occurred in Mobclick.flush(). ", localException);
/*     */     }
/*     */   }
/*     */ 
/*     */   void a(Context paramContext, String paramString1, String paramString2, long paramLong, int paramInt) {
/*     */     try {
/* 199 */       if ((paramContext == null) || (!a(paramString1, 128)) || (paramInt <= 0)) {
/* 200 */         Log.b("MobclickAgent", "invalid params in onEvent");
/* 201 */         return;
/*     */       }
/*     */ 
/* 204 */       if (this.n == null) {
/* 205 */         Log.e("MobclickAgent", "can't call onEvent before session is initialized");
/* 206 */         return;
/*     */       }
/*     */ 
/* 209 */       if ((paramString2 != null) && (!a(paramString2, 256))) {
/* 210 */         Log.b("MobclickAgent", "invalid label in onEvent");
/* 211 */         return;
/*     */       }
/* 213 */       this.d.a(this.n, paramString1, paramString2, paramLong, paramInt);
/*     */ 
/* 215 */       e(paramContext);
/*     */     }
/*     */     catch (Exception localException) {
/* 218 */       Log.b("MobclickAgent", "Exception occurred in Mobclick.onEvent(). ", localException);
/*     */     }
/*     */   }
/*     */ 
/*     */   void a(Context paramContext, String paramString, HashMap<String, String> paramHashMap, long paramLong) {
/*     */     try {
/* 224 */       if ((paramContext == null) || (TextUtils.isEmpty(paramString))) {
/* 225 */         Log.b("MobclickAgent", "invalid params in onKVEventEnd");
/* 226 */         return;
/*     */       }
/*     */ 
/* 229 */       if (!a(paramHashMap)) {
/* 230 */         return;
/*     */       }
/*     */ 
/* 233 */       if (this.n == null) {
/* 234 */         Log.e("MobclickAgent", "can't call onEvent before session is initialized");
/* 235 */         return;
/*     */       }
/*     */ 
/* 238 */       this.d.a(this.n, paramString, paramHashMap, paramLong);
/*     */ 
/* 240 */       e(paramContext);
/*     */     }
/*     */     catch (Exception localException) {
/* 243 */       Log.b("MobclickAgent", 
/* 244 */         "Exception occurred in Mobclick.onEvent(). ", localException);
/*     */     }
/*     */   }
/*     */ 
/*     */   private synchronized void i(Context paramContext)
/*     */   {
/* 250 */     SharedPreferences localSharedPreferences = j.e(paramContext);
/* 251 */     if (localSharedPreferences == null) {
/* 252 */       return;
/*     */     }
/*     */ 
/* 255 */     if (a(localSharedPreferences)) {
/* 256 */       this.n = b(paramContext, localSharedPreferences);
/* 257 */       Log.a("MobclickAgent", "Start new session: " + this.n);
/*     */     } else {
/* 259 */       this.n = c(paramContext, localSharedPreferences);
/* 260 */       Log.a("MobclickAgent", "Extend current session: " + this.n);
/*     */     }
/*     */   }
/*     */ 
/*     */   private synchronized void j(Context paramContext) {
/* 265 */     SharedPreferences localSharedPreferences = j.e(paramContext);
/* 266 */     if (localSharedPreferences == null) {
/* 267 */       return;
/*     */     }
/*     */ 
/* 270 */     long l1 = localSharedPreferences.getLong("start_millis", -1L);
/*     */ 
/* 272 */     if (l1 == -1L) {
/* 273 */       Log.b("MobclickAgent", 
/* 274 */         "onEndSession called before onStartSession");
/*     */     } else {
/* 276 */       long l2 = System.currentTimeMillis();
/*     */ 
/* 278 */       SharedPreferences.Editor localEditor = null;
/*     */ 
/* 280 */       if (g.j) {
/* 281 */         localEditor = m.a(localSharedPreferences, this.m, l1, l2);
/*     */       } else {
/* 283 */         localEditor = m.a(localSharedPreferences, this.x, l1, l2);
/* 284 */         this.x.clear();
/*     */       }
/*     */ 
/* 287 */       localEditor.putLong("start_millis", -1L);
/* 288 */       localEditor.putLong("end_millis", l2);
/*     */ 
/* 290 */       localEditor.commit();
/*     */     }
/*     */ 
/* 293 */     a(paramContext, localSharedPreferences);
/*     */ 
/* 295 */     a(paramContext, 5);
/*     */   }
/*     */ 
/*     */   private void a(Context paramContext, SharedPreferences paramSharedPreferences)
/*     */   {
/* 301 */     long l = System.currentTimeMillis();
/*     */ 
/* 303 */     if ((!g.i) || (l - paramSharedPreferences.getLong("last_fetch_location_time", 0L) < 10000L)) {
/* 304 */       return;
/*     */     }
/*     */ 
/* 307 */     SharedPreferences.Editor localEditor = o.a(paramContext, paramSharedPreferences);
/*     */ 
/* 309 */     if (localEditor != null)
/*     */     {
/* 311 */       localEditor.putLong("last_fetch_location_time", l);
/* 312 */       localEditor.commit();
/*     */     }
/*     */   }
/*     */ 
/*     */   private boolean a(SharedPreferences paramSharedPreferences) {
/* 317 */     long l1 = paramSharedPreferences.getLong("end_millis", -1L);
/* 318 */     long l2 = System.currentTimeMillis();
/* 319 */     if (l2 - l1 > g.d) {
/* 320 */       return true;
/*     */     }
/* 322 */     return false;
/*     */   }
/*     */ 
/*     */   private String b(Context paramContext, SharedPreferences paramSharedPreferences)
/*     */   {
/* 328 */     long l = System.currentTimeMillis();
/*     */ 
/* 330 */     String str = a(paramContext, l);
/*     */ 
/* 332 */     com.umeng.analytics.a.h localh = new com.umeng.analytics.a.h(paramContext, str);
/* 333 */     m localm = m.a(paramContext);
/*     */ 
/* 335 */     this.d.a(localh);
/* 336 */     this.d.a(localm);
/*     */ 
/* 338 */     SharedPreferences.Editor localEditor = paramSharedPreferences.edit();
/*     */ 
/* 340 */     localEditor.putString("session_id", str);
/* 341 */     localEditor.putLong("start_millis", l);
/* 342 */     localEditor.putLong("end_millis", -1L);
/*     */ 
/* 344 */     localEditor.commit();
/*     */ 
/* 346 */     a(paramContext, 4);
/*     */ 
/* 348 */     return str;
/*     */   }
/*     */ 
/*     */   private String a(Context paramContext, long paramLong)
/*     */   {
/* 353 */     String str = this.l == null ? com.umeng.common.b.q(paramContext) : this.l;
/* 354 */     StringBuilder localStringBuilder = new StringBuilder();
/* 355 */     localStringBuilder.append(paramLong)
/* 356 */       .append(str)
/* 357 */       .append(com.umeng.common.util.h.b(com.umeng.common.b.g(paramContext)));
/* 358 */     return com.umeng.common.util.h.a(localStringBuilder.toString());
/*     */   }
/*     */ 
/*     */   private String c(Context paramContext, SharedPreferences paramSharedPreferences)
/*     */   {
/* 363 */     Long localLong = Long.valueOf(System.currentTimeMillis());
/*     */ 
/* 365 */     SharedPreferences.Editor localEditor = paramSharedPreferences.edit();
/* 366 */     localEditor.putLong("start_millis", localLong.longValue());
/* 367 */     localEditor.putLong("end_millis", -1L);
/* 368 */     localEditor.commit();
/*     */ 
/* 370 */     return paramSharedPreferences.getString("session_id", null);
/*     */   }
/*     */ 
/*     */   private void d(Context paramContext, String paramString)
/*     */   {
/*     */     try
/*     */     {
/* 377 */       if (g.m) {
/* 378 */         this.d.a(paramString);
/*     */       } else {
/* 380 */         k localk = k.a(paramContext, paramString);
/* 381 */         localk.a(Long.valueOf(System.currentTimeMillis()));
/* 382 */         localk.a(paramContext);
/*     */       }
/*     */     } catch (Exception localException) {
/* 385 */       Log.a("MobclickAgent", "exception in save event begin info");
/*     */     }
/*     */   }
/*     */ 
/*     */   private int e(Context paramContext, String paramString) {
/* 390 */     int i = -1;
/*     */     try
/*     */     {
/* 393 */       long l = -1L;
/* 394 */       if (g.m) {
/* 395 */         l = this.d.b(paramString);
/*     */       } else {
/* 397 */         k localk = k.a(paramContext, paramString);
/* 398 */         l = localk.a().longValue();
/*     */       }
/*     */ 
/* 401 */       if (l > 0L)
/* 402 */         i = (int)(System.currentTimeMillis() - l);
/*     */     }
/*     */     catch (Exception localException) {
/* 405 */       Log.a("MobclickAgent", "exception in get event duration", localException);
/*     */     }
/*     */ 
/* 408 */     return i;
/*     */   }
/*     */ 
/*     */   void b(Context paramContext, String paramString) {
/* 412 */     if ((paramContext == null) || (!a(paramString, 128))) {
/* 413 */       Log.b("MobclickAgent", "invalid params in onEventBegin");
/* 414 */       return;
/*     */     }
/*     */ 
/* 417 */     d(paramContext, "_t" + paramString);
/*     */   }
/*     */ 
/*     */   void c(Context paramContext, String paramString) {
/* 421 */     if ((paramContext == null) || (TextUtils.isEmpty(paramString))) {
/* 422 */       Log.a("MobclickAgent", "input Context is null or event_id is empty");
/* 423 */       return;
/*     */     }
/* 425 */     int i = e(paramContext, "_t" + paramString);
/*     */ 
/* 427 */     if (i < 0) {
/* 428 */       Log.b("MobclickAgent", "event duration less than 0 in onEventEnd");
/* 429 */       return;
/*     */     }
/* 431 */     a(paramContext, paramString, null, i, 1);
/*     */   }
/*     */ 
/*     */   void a(Context paramContext, String paramString1, String paramString2) {
/* 435 */     if ((paramContext == null) || (!a(paramString1, 128)) || (!a(paramString2, 256))) {
/* 436 */       Log.b("MobclickAgent", "invalid params in onEventBegin");
/* 437 */       return;
/*     */     }
/* 439 */     d(paramContext, "_tl" + paramString1 + paramString2);
/*     */   }
/*     */ 
/*     */   void b(Context paramContext, String paramString1, String paramString2) {
/* 443 */     if ((paramContext == null) || (TextUtils.isEmpty(paramString2))) {
/* 444 */       Log.b("MobclickAgent", "invalid params in onEventEnd");
/* 445 */       return;
/*     */     }
/* 447 */     int i = e(paramContext, "_tl" + paramString1 + paramString2);
/* 448 */     if (i < 0) {
/* 449 */       Log.b("MobclickAgent", "event duration less than 0 in onEvnetEnd");
/* 450 */       return;
/*     */     }
/* 452 */     a(paramContext, paramString1, paramString2, i, 1);
/*     */   }
/*     */ 
/*     */   void a(Context paramContext, String paramString1, HashMap<String, String> paramHashMap, String paramString2)
/*     */   {
/* 462 */     if ((paramContext == null) || (TextUtils.isEmpty(paramString1)) || (TextUtils.isEmpty(paramString2))) {
/* 463 */       Log.b("MobclickAgent", "invalid params in onKVEventBegin");
/* 464 */       return;
/*     */     }
/*     */ 
/* 467 */     if (!a(paramHashMap)) {
/* 468 */       return;
/*     */     }
/*     */ 
/*     */     try
/*     */     {
/* 473 */       String str = paramString1 + paramString2;
/*     */ 
/* 475 */       this.d.a(str, paramHashMap);
/* 476 */       this.d.a(str);
/*     */     }
/*     */     catch (Exception localException) {
/* 479 */       Log.e("MobclickAgent", "exception in save k-v event begin inof", localException);
/*     */     }
/*     */   }
/*     */ 
/*     */   void c(Context paramContext, String paramString1, String paramString2) {
/* 484 */     if ((paramContext == null) || (TextUtils.isEmpty(paramString1)) || (TextUtils.isEmpty(paramString2))) {
/* 485 */       Log.b("MobclickAgent", "invalid params in onKVEventEnd");
/* 486 */       return;
/*     */     }
/*     */ 
/* 490 */     String str = paramString1 + paramString2;
/*     */ 
/* 492 */     int i = e(paramContext, str);
/* 493 */     if (i < 0) {
/* 494 */       Log.b("MobclickAgent", "event duration less than 0 in onEvnetEnd");
/* 495 */       return;
/*     */     }
/*     */ 
/* 498 */     a(paramContext, paramString1, this.d.c(str), i);
/*     */   }
/*     */ 
/*     */   boolean a(String paramString, int paramInt)
/*     */   {
/* 509 */     if (paramString == null) {
/* 510 */       return false;
/*     */     }
/*     */ 
/* 513 */     int i = paramString.getBytes().length;
/*     */ 
/* 515 */     if ((i == 0) || (i > paramInt)) {
/* 516 */       return false;
/*     */     }
/*     */ 
/* 519 */     return true;
/*     */   }
/*     */ 
/*     */   boolean a(Map<String, String> paramMap) {
/* 523 */     if ((paramMap == null) || (paramMap.isEmpty())) {
/* 524 */       Log.b("MobclickAgent", "map is null or empty in onEvent");
/* 525 */       return false;
/*     */     }
/*     */ 
/* 528 */     for (Map.Entry localEntry : paramMap.entrySet()) {
/* 529 */       if ((!a((String)localEntry.getKey(), 128)) || (!a((String)localEntry.getValue(), 256))) {
/* 530 */         Log.b("MobclickAgent", String.format("invalid key-<%s> or value-<%s> ", new Object[] { localEntry.getKey(), localEntry.getValue() }));
/* 531 */         return false;
/*     */       }
/*     */     }
/*     */ 
/* 535 */     return true;
/*     */   }
/*     */ 
/*     */   void d(Context paramContext) {
/*     */     try {
/* 540 */       if (!this.w.isEmpty()) {
/* 541 */         b(((f)this.w.peek()).a);
/*     */       }
/* 543 */       j(paramContext);
/*     */     } catch (Exception localException) {
/* 545 */       localException.printStackTrace();
/*     */     }
/*     */   }
/*     */ 
/*     */   public void b(Context paramContext, Throwable paramThrowable) {
/*     */     try {
/* 551 */       this.d.a(new com.umeng.analytics.a.d(paramThrowable));
/* 552 */       if (!this.w.isEmpty()) {
/* 553 */         b(((f)this.w.peek()).a);
/*     */       }
/* 555 */       j(paramContext);
/*     */     } catch (Exception localException) {
/* 557 */       Log.a("MobclickAgent", "Exception in onAppCrash", localException);
/*     */     }
/*     */   }
/*     */ 
/*     */   private final class a
/*     */     implements Runnable
/*     */   {
/* 132 */     private final Object b = new Object();
/*     */     private Context c;
/*     */     private int d;
/*     */ 
/*     */     a(Context paramInt, int arg3)
/*     */     {
/* 137 */       this.c = paramInt.getApplicationContext();
/*     */       int i;
/* 138 */       this.d = i;
/*     */     }
/*     */ 
/*     */     public void run() {
/*     */       try {
/* 143 */         synchronized (this.b) {
/* 144 */           switch (this.d) {
/*     */           case 0:
/* 146 */             b.a(b.this, this.c);
/* 147 */             break;
/*     */           case 1:
/* 149 */             b.b(b.this, this.c);
/*     */           }
/*     */         }
/*     */       }
/*     */       catch (Exception localException) {
/* 154 */         Log.b("MobclickAgent", 
/* 155 */           "Exception occurred in invokehander.", localException);
/*     */       }
/*     */     }
/*     */   }
/*     */ }

/* Location:           C:\Users\Administrator\Desktop\umeng_sdk.jar
 * Qualified Name:     com.umeng.analytics.b
 * JD-Core Version:    0.6.2
 */